package com.gagakuai.engine.impl.persistence.deploy;

import com.gagakuai.engine.exception.ActivitiIllegalArgumentException;
import com.gagakuai.engine.impl.persistence.entity.ProcessDefinitionEntity;
import com.gagakuai.model.bpmn.BpmnModel;

import java.util.List;

/*
 * @program: common-starters
 * @description: 部署实列管理器:所有的部署器都在这里，和外部交互也通过这里
 * @author: houhong
 * @create: 2023-01-02 15:10
 */
public class DeploymentManager {

    /*
     * 流程定义缓存 ---> 针对于Pvm级别的
     */
    protected DeploymentCache<ProcessDefinitionEntity> processDefinitionCache;

    protected DeploymentCache<BpmnModel> bpmnModelCache;

    /*
     * 流程定义信息缓存
     */
    protected ProcessDefinitionInfoCache processDefinitionInfoCache;

    /*
     * 收集所有的部署器
     */
    protected List<Deployer> deployers;


    public ProcessDefinitionEntity findDeployedProcessDefinitionById(String processDefinitionId) {

        if (processDefinitionId == null) {
            throw new ActivitiIllegalArgumentException("Invalid process definition id : null");
        }
        //从缓存中拿
        ProcessDefinitionEntity processDefinition = processDefinitionCache.get(processDefinitionId);

        if (processDefinition == null) {
            //// TODO: 2023/1/2 从数据库中拿 然后更新缓存
        }

        return processDefinition;

    }


}